package org.neuedu.ssmp.crm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;
import org.neuedu.ssmp.crm.entity.OrderList;
import org.neuedu.ssmp.crm.entity.Orders;
import org.neuedu.ssmp.crm.mapper.OrdersMapper;
import org.neuedu.ssmp.crm.service.IOrdersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author MoonHolder
 * @since 2019-12-09
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> implements IOrdersService {

    @Autowired
    private OrdersMapper ordersMapper;

    @Override
    public List<Orders> queryTime() {
        return ordersMapper.queryTime();
    }

    @Override
    public IPage<Orders> ordersPage(int pageIndex, int pageSize, int customerId) {
        return new LambdaQueryChainWrapper<>(baseMapper).eq(Orders::getCustomerId,customerId).page(new Page<>(pageIndex,pageSize));
    }

    @Override
    public IPage<OrderList> orderDetailPage(int pageIndex, int pageSize, int orderId) {
        QueryWrapper<OrderList> queryWrapper = new QueryWrapper<OrderList>().eq("order_id",orderId);
        return baseMapper.conditionPage(new Page<>(pageIndex,pageSize),queryWrapper);
    }

    @Override
    public List<Integer> cId() {
        return ordersMapper.cId();
    }
}
